/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans.validation;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

/**
 *
 * @author marcy
 */
public class MailValidator implements Validator {

    

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        
        String str = (String)value;
        if(!(str.matches("[0-9a-zA-Z@.]*") && str.contains("@") && str.contains(".")))   
            throw new ValidatorException(new FacesMessage("Ivalid Characters"));
        
    }
}

